package com.wofish.oauth.account.service;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.wofish.oauth.model.Accounts;
import org.springframework.stereotype.Service;


@Service("tokenService")
public class TokenService {

    public String getToken(Accounts accounts) {
        String token="";
        token= JWT.create().withAudience(accounts.getUid())// 将 user id 保存到 token 里面
                .sign(Algorithm.HMAC256(accounts.getPassword()));// 以 password 作为 token 的密钥
        return token;
    }
}
